<!--
 * @Description:大屏模版头部区域
 * @Author: gaoyunpeng
 * @Date: 2022-01-21 22:17:40
 * @LastEditors: gaoyunpeng
-->
<template>
  <header :style="cssStyle">
    <h1 class="title">大屏数据系统</h1>
    <div class="content">
      <div class="data">
        <DateTime></DateTime>
      </div>
      <ul class="menu">
        <li
          :class="{ active: item.path === currentPage }"
          v-for="item in menuList"
          :key="item.path"
          @click="doClickMenu(item)"
        >
          {{ item.title }}
        </li>
      </ul>
      <div class="layout" @click="layout">
        <img
          src="@/assets/images/bigscreen/layout.png"
          alt=""
          title="退出按钮"
        />
      </div>
    </div>
  </header>
</template>

<script>
import DateTime from '@/components/dataFormat/index.vue'
import { removeToken } from '@/utils/auth'
import { navBarBackgroundPicture } from '@/settings.js'
export default {
  components: {
    DateTime
  },
  computed: {
    menuList() {
      return [
        {
          title: '大屏可视化',
          name: 'FingerprintLibrary',
          path: '/bigscreen'
        },
        {
          title: '菜单1',
          name: 'menu1',
          path: '/menu1'
        },
        {
          title: '菜单2',
          name: 'menu2',
          path: '/menu2'
        },
        {
          title: '系统管理',
          name: 'manage',
          path: '/manage'
        }
      ]
    },
    cssStyle() {
      return {
        background: `url(${navBarBackgroundPicture})`,
        backgroundSize: '100% 100%'
      }
    }
  },
  data() {
    return {
      currentPage: ''
    }
  },
  watch: {
    $route: {
      handler: function (route) {
        const path = route.path
        if (path) {
          this.currentPage = path
        }
      },
      immediate: true
    }
  },
  methods: {
    doClickMenu(item) {
      this.$router.push(item.path)
    },
    layout() {
      removeToken()
      this.$router.push('/login')
    }
  }
}
</script>

<style lang="scss" scoped>
@import '~@/styles/mixin.scss';
header {
  position: relative;
  width: 100%;
  height: 100px;
  padding: 0 20px;

  .content {
    display: flex;
    width: 100%;
    height: 100%;

    .data {
      line-height: 80px;
    }
    .menu {
      width: calc(100% - 250px);
      display: flex;
      margin-top: 20px;
      margin-left: 10px;
      li {
        width: 140px;
        height: 40px;
        font-size: 14px;
        @include font-color('normal_text_color');
        @include border('border_color', 0.5, 1px, solid, '', '');
        line-height: 40px;
        text-align: center;
        cursor: pointer;
        @include bg_color('pannel_bg_color', 1);

        border: 0;
        &:nth-child(1) {
          margin-right: 100px;
        }
        &:nth-child(2) {
          margin-right: 700px;
        }
        &:nth-child(3) {
          margin-right: 100px;
        }
      }
      .active {
        @include font-color('active_color');
        font-weight: 500;
      }
    }
    .layout {
      width: 50px;
      padding-top: 10px;
      img {
        width: 100%;
      }
    }
  }
  h1 {
    position: absolute;
    left: 50%;
    line-height: 1;
    transform: translate(-50%);
    font-size: 38px;
    font-family: PingFangSC, PingFangSC-Medium;
    font-weight: 500;
    letter-spacing: 3px;
    background-image: -webkit-linear-gradient(90deg, #1abce3 33%, #e5f1f5 85%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .header-right {
    border: 1px solid red;
    display: flex;
    align-items: center;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-80%);
    .item {
      @include font_color('normal_text_color');
    }
    .layout {
      width: 56px;
      height: 56px;
      margin: 0 20px;

      img {
        width: 100%;
      }
    }
  }
}
</style>
